package com.showgood.beans.handler.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.showgood.beans.handler.SingleVoSingleReplyHandler;
import com.showgood.beans.proxy.GameUtil;
import com.showgood.beans.service.impl.CityService;
import com.showgood.beans.service.impl.ManService;
import com.showgood.meta.City;
import com.showgood.socket.Session;
import com.showgood.vo.CityDetailVO;
import com.showgood.vo.IdVO;
import com.showgood.vo.RemoteMessage;

@Component
public class QueryCityDetailHandler extends SingleVoSingleReplyHandler<IdVO, CityDetailVO> {
	@Autowired
	private CityService cityService;
	@Autowired
	private ManService manService;
	@Override
	public int[] handleMessage() {
		return new int[]{RemoteMessage.REMOTE_QUERY_CITY_DETAIL};
	}
	@Override
	protected CityDetailVO handle(Session userSession, IdVO q) {
		City city = cityService.get(q.id);
		CityDetailVO vo = GameUtil.copyTo(city, new CityDetailVO());
		vo.mancnt = manService.getCityManCount(q.id);
		return vo;
	}
}
